package com.bs.elasticsearch.controller;

import com.bs.elasticsearch.service.ElasticSearchService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author bingshao
 * @date 2023/3/17
 **/
@RestController
@RequestMapping("/elastic")
public class ElasticSearchController {

    @Resource
    private ElasticSearchService elasticSearchService;

    @PostMapping("/createIndex")
    public void createIndex() {
        elasticSearchService.createIndex();
    }

    @PostMapping("/save")
    public void save() {
        elasticSearchService.save();
    }

    @PostMapping("/batchSave")
    public void batchSave() {
        elasticSearchService.batchSave();
    }

    @PostMapping("/update")
    public void update() {
        elasticSearchService.update();
    }

    @PostMapping("/batchUpdate")
    public void batchUpdate() {
        elasticSearchService.batchUpdate();
    }

    @GetMapping("/search")
    public void search() {
        elasticSearchService.search();
    }

    @GetMapping("/searchScroll")
    public void searchScroll() {
        elasticSearchService.searchScroll();
    }

    @GetMapping("/aggMetric")
    public void aggMetric() {
        elasticSearchService.aggMetric();
    }

    @GetMapping("/aggBucket")
    public void aggBucket() {
        elasticSearchService.aggBucket();
    }

}
